|
In time series analysis, dynamic time warping (DTW) is an algorithm for measuring similarity between two temporal sequences which may vary in time or speed. For instance, similarities in walking patterns could be detected using DTW, even if one person was walking faster than the other, or if there were accelerations and decelerations during the course of an observation. DTW has been applied to temporal sequences of video, audio, and graphics data — indeed, any data which can be turned into a linear sequence can be analyzed with DTW. A well known application has been automatic speech recognition, to cope with different speaking speeds. Other applications include speaker recognition and online signature recognition. Also it is seen that it can be used in partial shape matching application. In general, DTW is a method that calculates an optimal match between two given sequences (e.g. time series) with certain restrictions. The sequences are "warped" non-linearly in the time dimension to determine a measure of their similarity independent of certain non-linear variations in the time dimension. This sequence alignment method is often used in time series classification. Although DTW measures a distance-like quantity between two given sequences, it doesn't guarantee the triangle inequality to hold. == Implementation == This example illustrates the implementation of the dynamic time warping algorithm when the two sequences s and t are strings of discrete symbols. For two symbols x and y , d(x, y) is a distance between the symbols, e.g. d(x, y) = | x - y |
We sometimes want to add a locality constraint. That is, we require that if s() is matched with t() , then | i - j | is no larger than w , a window parameter.We can easily modify the above algorithm to add a locality constraint (differences marked in ''bold italic'' ).However, the above given modification works only if | n - m | is no larger than w , i.e. the end point is within the window length from diagonal. In order to make the algorithm work, the window parameter w must be adapted so that | n - m | ≤ w (see the line marked with (*) in the code). int DTWDistance(s: array (), t: array ()'', w: int'') { DTW := array (0..m ) ''w := max(w, abs(n-m))'' // adapt window size ( *) ''for i := 0 to n'' '' for j:= 0 to m'' '' DTW(j ) := infinity'' DTW(0 ) := 0 for i := 1 to n for j := ''max(1, i-w) to min(m, i+w)'' cost := d(s(), t()) DTW(j ) := cost + minimum(DTW(j ), // insertion DTW(j-1 ), // deletion DTW(j-1 )) // match return DTW(m ) 抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)』 ■ウィキペディアで「Dynamic time warping」の詳細全文を読む スポンサード リンク
|